

import turtle
import random

poss = []
point = [0, 300]

def gen_points(n=5):
    for i in range(n):
        poss.append([320, random.randint(-320, 320)])
    turtle.ontimer(gen_points, 3000)


def goto(pos):
    turtle.up()
    turtle.goto(pos)
    turtle.down()


def move():
    turtle.clear()
    n = 0
    is_stop = False
    while n < len(poss):
        goto(poss[n])
        turtle.dot(20,'cyan')
        if abs(point[0]-poss[n][0]) < 20 and abs(point[1]-poss[n][1]) < 20:
            is_stop = True
        poss[n][0] -= 10
        if poss[n][0] < -330:
            poss.pop(n)
        else:
            n+=1

    goto(point)
    point[1] -= 10
    turtle.dot(20, 'orange')
    if not is_stop:
        turtle.ontimer(move, 300)

def click(x, y):
    point[1] += 20

# 去除动画效果
turtle.tracer(False)
gen_points(5)
move()
turtle.onscreenclick(click)
turtle.done()


